/**
 * class name: ipost,
 * copyright: maximus zhang,
 * License: MIT-LICENSE,
 * contact: maximus.zhang@gmail.com,
 * required-js: http://hcjs.googlecode.com/svn/trunk/core.js,
 * update: http://hcjs.googlecode.com/svn/trunk/ipost.js
 * ▼▲ &#9660; &#9650; > &#9658; < &#9668;
 */
function ipost(){
    var A = arguments,
        _ = this;
    _ = ext( _, ext( {
        id : 'ipost'+ now(3),
        elem : me.body,
        cssname : 'ipost',
        icos:{
            author:'/icos/user.png',
            date:'/icos/date.png',
            folder:'/icos/folder.png',
            tags:'/icos/tag_purple.png',
            hits:'/icos/cursor.png',
            comments:'/icos/comments.png'
            },
        posts:[]
        }, A[0] ) );

    _.uitype = 'ipost';

    _.elem = $(_.elem) || me.body;

}
ipost.prototype = {

    setInfo : function (a, d, f, t, h, c, el) {
        var _ = this,
            ai = elm('img').setClass('ico').attr('src', _.icos.author).appendTo(el),
            ae = elm('span').html(a).appendTo(el),
            di = elm('img').setClass('ico').attr('src', _.icos.date).appendTo(el),
            de = elm('span').html(d).appendTo(el),
            fi = elm('img').setClass('ico').attr('src', _.icos.folder).appendTo(el),
            fe = elm('span').html(f).appendTo(el),
            ti = elm('img').setClass('ico').attr('src', _.icos.tags).appendTo(el),
            te = elm('span').html(t).appendTo(el),
            hi = elm('img').setClass('ico').attr('src', _.icos.hits).appendTo(el),
            he = elm('span').html(h).appendTo(el),
            ci = elm('img').setClass('ico').attr('src', _.icos.comments).appendTo(el),
            ce = elm('span').html(c).appendTo(el);

    return _;
    },

    add : function (m) {
        var _ = this;

        var tit = elm('div').setClass('postit').appendTo(_.$),
            tat = elm('a').setClass('tat').attr('href', m.url||'#').html(m.title).appendTo(tit),
            con = elm('div').setClass('postcont').html(m.content).appendTo(_.$),
            fot = elm('div').setClass('postinfo').appendTo(_.$);
        _.setInfo(m.author, m.date, m.folder, m.tags, m.hits, m.comments, fot);

    return _;
    },

    init : function () {
        var _ = this;
        if ( !_.$ ) {
            _.$ = elm( 'div' ).setClass('ipost').appendTo( _.elem );
            _.$.id = _.id = !$(_.id) ? _.id : '_ipost'+ _.id;
            p(_, 'cssname') && _.$.addClass(_.cssname);
        }

        _.add(_.posts);

    return _;
    }
};